/*
 * Copyright (c) 2006-2025, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2025-10-14     RT-Thread    aht20 driver
 */

#ifndef __DRV_AHT20_H__
#define __DRV_AHT20_H__

#include <rtthread.h>
#include <rtdevice.h>

#define AHT20_I2C_BUS_NAME      "i2c3"
#define AHT20_I2C_ADDR          0x38

#define AHT20_CMD_CALIBRATE     0xBE
#define AHT20_CMD_TRIGGER       0xAC
#define AHT20_CMD_SOFT_RESET    0xBA

struct aht20_device
{
    struct rt_i2c_bus_device *i2c;
    rt_mutex_t lock;
};

typedef struct aht20_device *aht20_device_t;

aht20_device_t aht20_init(const char *i2c_bus_name);
void aht20_deinit(aht20_device_t dev);
rt_err_t aht20_read_temperature_humidity(aht20_device_t dev, float *temperature, float *humidity);

#endif
